<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>active-event-ack</title>
    <%@ include file="../include/common.jsp"%>
    <%@ include file="../include/form.jsp"%>
    <%@ include file="../include/table.jsp"%>
    <script type="text/javascript">
    $(function(){
    	//加载grid
		var oTable=	$('#remarkList').dataTable({
			"bProcessing": false, 
			"bServerSide": true,
			"sServerMethod": 'POST',
			"sAjaxSource":'${pageContext.request.contextPath}/event/event-view!remarksList.action?eventId='+${id},
			"bPaginate": false,
			"bSort": true,
			"bFilter":false,
			"bJQueryUI":false,
			"aoColumns":[
				{"mDataProp":"time","bSortable": false},
				{"mDataProp":"person","bSortable": false},
				{"mDataProp":"remarks","bSortable": false}
			], 
			 "oLanguage": { 
			 		 		"sZeroRecords": "没有记录",
							"sInfo": "  ", 
							"sInfoEmpty": "  "
			},
		    "fnServerParams":function(aoData){
		    }
		});
		 $.formValidator.initConfig({formid:"myform"
	          ,onerror:function(msg){}
	          ,onsuccess:function(){
	        	  		ack();
	          			return false;
	          }
	     });
		 //$("#remarks").formValidator({onshow:"不能为空 长度(1-50)",onfocus:"不能为空 长度(1-50)",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"}).inputValidator({min:1,max:50,onerror:"长度非法"});
	});
  function ackAndConfirm(){
	  if($("#remarks").val() == ''){
			getTopWin(window).getMessageBox().alert("备注内容不能为空","提示");
			return false;
		}
	  var id = $("#id").val();
	  var remarks= $("#remarks").val()
	  $.ajax({
		   type: "POST", 
		   url: "${pageContext.request.contextPath}/event/active-event!ackAndConfirm.action", //请求的action
		   data: "id="+id+"&remarks="+remarks, //传的参数
		   dataType: 'json',
		   success: function(data){ //结果
				   var pWin = getTopWin(window).currentWin["active-event-singleAck"];
				   if(data.flag == "false"){
						pWin.showMessage("事件已认领或清除");
					}	   
		   			pWin.datagrid();
				   getTopWin(window).closejBox("active-event-singleAck");
		   }
	});
  }
  function ack(){
	  if($("#remarks").val() == ''){
			getTopWin(window).getMessageBox().alert("备注内容不能为空","提示");
			return false;
		}
	  //提交
	$.ajax({
		   type: "POST", 
		   url: "${pageContext.request.contextPath}/event/active-event!ack.action", //请求的action
		   data: $("#myform").serialize(), //传的参数
		   dataType: 'json',
		   success: function(data){ //结果
				   var pWin = getTopWin(window).currentWin["active-event-singleAck"];
				   if(data.flag == "false"){
						pWin.showMessage("事件已认领或清除");
					}	   
		   			pWin.datagrid();
				   getTopWin(window).closejBox("active-event-singleAck");
		   }
	});
  }
  function closewin(){
	  getTopWin(window).closejBox("active-event-singleAck");
  }
  </script>
  </head>
  
  <body class="padding-8">
   <form action="" id="myform" name="myform" method="post">
   			<table id="remarkList" width="100%" cellpadding="0" cellspacing="0"
				border="0" class="display">
				<thead>
					<tr>
						<th width="120">时间</th>
						<th width="50">备注人</th>
						<th>备注</th>
					</tr>
				</thead>
			</table>
    		<table class="table_eidt">
    			<tr>
	    			<label><img src="/bsm/style/default/bsm/images/pencil.png">我要备注</label>
    			</tr>
    			<tr>
	    			<textarea id="remarks" name="remarks" rows="3" style="width: 100%;overflow: hidden;" ></textarea>
	    				<!-- <span id="remarksTip" style="width:200px"></span>  -->
    			</tr>
    		</table>
    		<div align="center" style="padding-top: 9px;">
    			<input type="button" id="ackConfirm" name="ackConfirm" value="认领并清除" class="btn-4" onclick="ackAndConfirm();">
	    		<input type="button" id="ackButton" name="ackButton" value="认领" class="btn-4" onclick="ack();">
	    		<input type="button" value="取消" onclick="closewin();" class="btn-4">
    		</div>
    		<input type="hidden" id="id" name="id" value=${id}>
    	</form>
  </body>
</html>
